package view.components;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;

import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

public class FormChangeListener extends Observable implements ActionListener, DocumentListener {
	private boolean hasChanged = false;

	@Override
	public void changedUpdate(DocumentEvent arg0) {
		setChanged(true);
	}

	@Override
	public void insertUpdate(DocumentEvent arg0) {
		setChanged(true);
	}

	@Override
	public void removeUpdate(DocumentEvent arg0) {
		setChanged(true);
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		setChanged(true);
	}
	
	public boolean hasChanged(){
		return hasChanged;
	}
	
	public void setChanged(boolean hasChanged){
		this.hasChanged = hasChanged;
		setChanged();
		notifyObservers(this);
	}

	public void reset() {
		setChanged(false);
	}

}
